/* -----------------------------------------------------------------------
 * Becky Kluth
 * CS 362
 * Assignment 3: cardtest2.c to test council_room card 
 *
 * cardtest2: cardtest2.c dominion.o rngs.o
 *      gcc -o cardtest2 -g  cardtest2.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//set NOISY_TEST to 0 to remove printfs from output (this macro taken from the example)
#define NOISY_TEST 0

int main() {
    int seed = 1000;					//initiate a game with 4 players
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState G;
	int startingHandCount;
	int startingNumBuys;
	int startingOtherCount1, startingOtherCount2, startingOtherCount3;
	int noCrash;

    initializeGame(numPlayer, k, seed, &G);

	printf("Testing card: council_room\n");
	startingHandCount = G.handCount[0];		//get player 0 hand count
	startingNumBuys = G.numBuys;			//get current number of buys
	startingOtherCount1 = G.handCount[1];	//get other three players' hand counts
	startingOtherCount2 = G.handCount[2];
	startingOtherCount3 = G.handCount[3];

#if (NOISY_TEST == 1)
     printf("Test player 0 starts with %d cards in hand and %d buys.\n", startingHandCount, startingNumBuys);
	 printf("Test player 1 starts with %d cards in hand.\n", startingOtherCount1);
	 printf("Test player 2 starts with %d cards in hand.\n", startingOtherCount2);
	 printf("Test player 3 starts with %d cards in hand.\n", startingOtherCount3);
#endif

	noCrash = cardEffect(council_room, 0, 0, 0, &G, 1, 0);		//council_room card, should add 4 cards and 1 buy, cause all other players to draw 1 card, 
																				//and cause active player to discard 1 card
	assert(noCrash == 0);											//check for crashing
	
	assert(G.handCount[0] == startingHandCount + 3);				//+4 cards, -1 discard = +3 overall cards
	assert(G.numBuys == startingNumBuys + 1);						//+1 buy

	assert(G.handCount[1] == startingOtherCount1 + 1);				//other players each +1 card
	assert(G.handCount[2] == startingOtherCount2 + 1);
	assert(G.handCount[3] == startingOtherCount3 + 1);

#if (NOISY_TEST == 1)
    printf("Test player 0 ends with %d cards in hand and %d buys.\n", G.handCount[0], G.numBuys);
	printf("Test player 1 ends with %d cards in hand.\n", G.handCount[1]);
	printf("Test player 2 ends with %d cards in hand.\n", G.handCount[2]);
	printf("Test player 3 ends with %d cards in hand.\n", G.handCount[3]);
#endif
	
    printf("All tests passed!\n");

    return 0;
}
